using System;
using System.Collections;
using System.Collections.Specialized;
using Sedna.Core.Common;

namespace Sedna.Core.Controller.Menu
{
	public sealed class MenuUtils
	{
		private MenuUtils()
		{
		}

		public static string ExtractMenuLevel1Param(IExecutionContext executionContext)
		{
			string menu_level_1 = (string)executionContext.GetScopedValue("menu_level_1", Scope.Request);
			if(menu_level_1 == null || menu_level_1 == string.Empty)
			{
				return menu_level_1;
			}
			if(menu_level_1.IndexOf(',', 0) < 0)
			{
				return menu_level_1;
			}
			return menu_level_1.Substring(menu_level_1.LastIndexOf(',') + 1);
		}

        public static string ExtractMenuLevel2Param(IExecutionContext executionContext)
		{
			string menu_level_1 = (string)executionContext.GetScopedValue("menu_level_2", Scope.Request);
			if(menu_level_1 == null || menu_level_1 == string.Empty)
			{
				return menu_level_1;
			}
			if(menu_level_1.IndexOf(',', 0) < 0)
			{
				return menu_level_1;
			}
			return menu_level_1.Substring(menu_level_1.LastIndexOf(',') + 1);
		}

	}
}
